<?php

    $current_year = date('Y');
    $unix_timestamp = time();
    $max_year = $current_year + 2;

    echo $javascript->link('language_experiences');

?>

<script>

    $(function() {
        
        init_dialog_button('add_language', 'language_form');
        
        language_form_dialog("<?php echo $this->Html->url(array(
                                                            'controller' => 'LanguageExperiences',
                                                            'action'    => 'add_language'
                                                        )); ?>");
                                                                
        $( '#LanguageExperienceMotherLanguage' ).click(function() {
            $( '#LanguageExperienceListeningLevelId option[value="1"]' ).attr('selected', 'selected');
            $( '#LanguageExperienceReadingLevelId option[value="1"]' ).attr('selected', 'selected');
            $( '#LanguageExperienceSpokenInteractionLevelId option[value="1"]' ).attr('selected', 'selected');
            $( '#LanguageExperienceSpokenProductionLevelId option[value="1"]' ).attr('selected', 'selected');
            $( '#LanguageExperienceWritingLevelId option[value="1"]' ).attr('selected', 'selected');
        })                                                        
    })

</script>

<div id="language_form" title="Aggiungi Lingua">
    <p class="validateTips">Tutte i campi sono obbligatori.</p>
    
    <form>
    <fieldset>
            <label for="language_name">Nome</label>
            <input type="text" name="language_name" id="language_name" class="text ui-widget-content ui-corner-all" />
    </fieldset>
    </form>

</div>

<?php

    echo $form->create('LanguageExperience');
    
?>

<fieldset>
    <legend>
        Nuova esperienza di lavoro
    </legend>

<?php
    
    echo $form->input('language_id', array(
                                 'empty' => '-- Seleziona --',
                                 'type' => 'select',
                                 'options' => $languages,
                                 'label' => 'Lingua'));   
    echo $html->link('Aggiungi Lingua', '#', array('onclick'=>'return false;', 'id'=>'add_language', 'class'=>''));
    
    echo $form->input('mother_language', array(
                             'type' => 'checkbox',
                             'value' => 1,
                             'label' => 'Lingua madre'));
    echo $form->inputs(array(
                    'legend' => 'Livelli',
                    'listening_level_id' => array(
                             'empty' => '-- Seleziona --',
                             'type' => 'select',
                             'options' => $language_levels,
                             'label' => 'Listening level'),
                    'reading_level_id' => array(
                             'empty' => '-- Seleziona --',
                             'type' => 'select',
                             'options' => $language_levels,
                             'label' => 'Reading level'),
                    'spoken_interaction_level_id' => array(
                             'empty' => '-- Seleziona --',
                             'type' => 'select',
                             'options' => $language_levels,
                             'label' => 'Spoken interaction level'),
                    'spoken_production_level_id' => array(
                             'empty' => '-- Seleziona --',
                             'type' => 'select',
                             'options' => $language_levels,
                             'label' => 'Spoken interaction level'),
                    'writing_level_id' => array(
                             'empty' => '-- Seleziona --',
                             'type' => 'select',
                             'options' => $language_levels,
                             'label' => 'Writing level'),
                    'person_id' => array(
                             'type' => 'hidden',
                             'value' => $person_id)));

?>
    
</fieldset>

<?php

echo $form->end('Salva');

?>